package io.zhengsh.juc._2synchronized1.biasedlock;

import org.openjdk.jol.info.ClassLayout;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

//@Slf4j
public class BiasedLockStateTest {


    private static Logger log = LoggerFactory.getLogger(BiasedLockStateTest.class);

    public static void main(String[] args) throws InterruptedException {
        log.debug(ClassLayout.parseInstance(new Object()).toPrintable());
        Thread.sleep(5000);
        Object obj1 = new Object();
        log.debug(ClassLayout.parseInstance(obj1).toPrintable());
        new Thread(new Runnable() {
            @Override
            public void run() {
                log.debug("start ... \r\n" + ClassLayout.parseInstance(obj1).toPrintable());
                synchronized (obj1) {
                    log.debug("lock ... \r\n" + ClassLayout.parseInstance(obj1).toPrintable());

                    try {
                        obj1.wait(10);
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                    log.debug("wait ... \r\n" + ClassLayout.parseInstance(obj1).toPrintable());

                    //obj1.notify();
                    //log.debug("notify ... \r\n" + ClassLayout.parseInstance(obj1).toPrintable());

                    //obj1.hashCode();
                    //log.debug("hashCode ... \r\n" + ClassLayout.parseInstance(obj1).toPrintable());
                }
                log.debug("unlock ... \r\n" + ClassLayout.parseInstance(obj1).toPrintable());
            }
        }, "thread0").start();

        Thread.sleep(5000);
        log.debug(ClassLayout.parseInstance(obj1).toPrintable());
    }
}
